package com.skd.mall.product.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skd.common.utils.PageUtils;
import com.skd.common.utils.Query;

import com.skd.mall.product.dao.CategoryBrandRelationDao;
import com.skd.mall.product.entity.CategoryBrandRelationEntity;
import com.skd.mall.product.service.CategoryBrandRelationService;

import javax.swing.text.html.parser.Entity;


@Service("categoryBrandRelationService")
public class CategoryBrandRelationServiceImpl extends ServiceImpl<CategoryBrandRelationDao, CategoryBrandRelationEntity> implements CategoryBrandRelationService {

    QueryWrapper<CategoryBrandRelationEntity> wrapper= new QueryWrapper<>();
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CategoryBrandRelationEntity> page = this.page(
                new Query<CategoryBrandRelationEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageByBrandId(Map<String, Object> params) {
        String brandId = (String) params.get("brandId");
        IPage<CategoryBrandRelationEntity> page = this.page(
                new Query<CategoryBrandRelationEntity>().getPage(params),
                wrapper.eq("brand_id",brandId)
        );
        return new PageUtils(page);
    }

    @Autowired
    private CategoryBrandRelationDao categoryBrandRelationDao;

    @Override
    public List<CategoryBrandRelationEntity> queryCategoryBrandRelation(Long catId) {
        List<CategoryBrandRelationEntity> list = categoryBrandRelationDao.selectList(
                new QueryWrapper<CategoryBrandRelationEntity>().eq("catelog_id", catId)
        );
        return list;
    }

}